﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities;
using ueEngine.Biz.Inf.LogicEntity.SupportData;

namespace ueEngine.Biz.Inf.LogicEntity
{
    public class ApplicationFormModel : IAccessible<ApplicationForm, ApplicationFormModel>
    {
        #region self
        public int Id { get; set; }
        public string Name { get; set; }
        public Gender Gender { get; set; }
        public int Age { get; set; }
        public string IdNo { get; set; }
        public string Job { get; set; }
        public string Remark { get; set; }
        public string Phone { get; set; }
        #endregion



        protected override void Covariant(ApplicationForm dbModel)
        {
            if (dbModel != null)
            {
                this.Id = dbModel.Id;
                this.Name = dbModel.Name;
                this.Gender = dbModel.Gender ? Gender.Male : Gender.Female;
                this.Age = dbModel.Age;
                this.IdNo = dbModel.IdNo;
                this.Job = dbModel.Job;
                this.Remark = dbModel.Remark;
                this.Phone = dbModel.Phone;
            }
        }

        protected override ApplicationForm Inverter(ApplicationFormModel model)
        {
            if (model != null)
            {
                return new ApplicationForm()
                {
                    Age = model.Age,
                    Gender = model.Gender == LogicEntity.Gender.Male,
                    Id = model.Id,
                    IdNo = model.IdNo,
                    Job = model.Job,
                    Name = model.Name,
                    Remark = model.Remark,
                    Phone = model.Phone
                };
            }
            return null;
        }
    }
}
